home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.anim;
- import java.awt.Point;
-
- /**
- * This is a sample trajectory. It implements a line trajectory,
- * given a pacer object to do the pacing transformation.
- *
- * @author Ian Smith
- */
- public class line_trajectory implements trajectory {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * This holds the pacer we are using.
- */
- protected pacer _pacer;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Origin in x.
- */
- protected int _x_origin;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Origin in y.
- */
- protected int _y_origin;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Amount to move in x.
- */
- protected int _delta_x;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Amount to move in y.
- */
- protected int _delta_y;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * This does the work for this trajectory. It maps a point in time
- * to a Point object. <p>
- *
- * @param double parm the amount of time to be mapped (in the range 0.0 to
- * 1.0)
- */
- public Object object_for_parm(double parm) {
- double parameter=_pacer.pace(parm); // run it through the pacer
- int newx, newy;
-
- newx=_x_origin+(int)(parameter * (double)_delta_x);
- newy=_y_origin+(int)(parameter * (double)_delta_y);
- return new Point(newx, newy);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * This constructs this trajectory, given two points.
- *
- * @param int x1 starting x coordinate
- * @param int y1 starting y coordinate
- * @param int x2 ending x coordinate
- * @param int y2 ending y coordinate
- */
- public line_trajectory(int x1, int y1, int x2, int y2, pacer p) {
-
- /* get the vars set up */
- _x_origin=x1;
- _delta_x=x2-x1;
- _y_origin=y1;
- _delta_y=y2-y1;
-
- /* copy the pacing function */
- _pacer=p;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Return the pacing function.
- * @return pacer the pacing function we are using for this trajectory
- */
- public pacer pacing_function() { return _pacer;};
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-